package com.anbao.newanbao;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.anbao.dataBean.HistoryAlarmBean;

public class HistoryAlarmItemAdapter extends BaseAdapter {

	private List<HistoryAlarmBean> files;
	private LayoutInflater inflater;
//	private OnClickListener listener;

	public HistoryAlarmItemAdapter(Context context, List<HistoryAlarmBean> files) {
		inflater = LayoutInflater.from(context);
		this.files = files;
//		this.listener = listener;
	}

	@Override
	public int getCount() {
		return files.size();
	}

	@Override
	public Object getItem(int position) {
		return files.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		HistoryAlarmHolder holder = null;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.history_alarm_item, parent, false);
			holder = new HistoryAlarmHolder();
			holder.time = (TextView) convertView.findViewById(R.id.time);
			holder.val = (TextView) convertView.findViewById(R.id.value);
			holder.state = (TextView) convertView.findViewById(R.id.state);
			convertView.setTag(holder);
		} else {
			holder = (HistoryAlarmHolder) convertView.getTag();
		}
		HistoryAlarmBean item = files.get(position);

		holder.time.setText(item.getTime());
		
		holder.val.setText(item.getValue());
		
		if(item.isState()){
			holder.state.setText("状态：已处理");
			
		}else{
			holder.state.setText("状态：未处理");
			
		}
//		holder.selectBtn.setOnClickListener(listener);
		return convertView;
	}

	
	class HistoryAlarmHolder{
		
		public TextView time;
		public TextView val;
		public TextView state;
		
		
	}
	
	
}